//
//  TopDetailTableViewHeader.m
//  MyMovie
//
//  Created by apple on 16/5/21.
//  Copyright © 2016年 ljp. All rights reserved.
//

#import "TopDetailTableViewHeader.h"

@implementation TopDetailTableViewHeader

//@property (strong, nonatomic) IBOutlet UIImageView *detailImageView;
//@property (strong, nonatomic) IBOutlet UILabel *titleLable;
//@property (strong, nonatomic) IBOutlet UILabel *directorsLable;
//@property (strong, nonatomic) IBOutlet UILabel *actorsLable;
//@property (strong, nonatomic) IBOutlet UILabel *typeLable;
//@property (strong, nonatomic) IBOutlet UILabel *countryAndYearLable;
//@property (strong, nonatomic) IBOutlet UIScrollView *detailScrollView;

-(void)setMovieDetail:(MovieDetail *)movieDetail {

    //设置图片
    NSURL *url = [NSURL URLWithString:movieDetail.imageName];
    [_detailImageView sd_setImageWithURL:url];
    //设置中文标题
    _titleLable.text = movieDetail.nameCn;
    //把导演数组里的字符串拿出来
    NSString *string = [movieDetail.directorsArray componentsJoinedByString:@"、"];
    _directorsLable.text = [NSString stringWithFormat:@"导演:%@", string];
    //把演员数组里的字符串拿出来
    string = [movieDetail.actorsArray componentsJoinedByString:@"、"];
    _actorsLable.text = [NSString stringWithFormat:@"主演:%@", string];
    //把类型拿出来
    string = [movieDetail.typeArray componentsJoinedByString:@"、"];
    _typeLable.text = [NSString stringWithFormat:@"类型:%@", string];
    //设置国家和地区
    _countryAndYearLable.text = movieDetail.countryAndYear;

    [self createScrollViewWithMovieDetail:movieDetail];
}

- (void)createScrollViewWithMovieDetail:(MovieDetail *)movieDetail {


    NSArray *array = movieDetail.scrollViewImageArray;
    CGFloat width = _detailScrollView.height - 20;

    for (int i = 0; i < array.count; i++) {


        UIImageView *imageView = [[UIImageView alloc] init];
        [imageView sd_setImageWithURL:[NSURL URLWithString:array[i]]];
        imageView.frame = CGRectMake((width+5)*i+5, 10, width, width);

        imageView.layer.cornerRadius = 5;
        //imageView特殊,弯曲需加上这个属性;
        imageView.layer.masksToBounds = YES;
        [_detailScrollView addSubview:imageView];
    }
    _detailScrollView.contentSize = CGSizeMake(array.count*(width+5)+5, 0);
    //边缘厚度颜色
    _detailScrollView.layer.borderColor = [UIColor whiteColor].CGColor;
    _detailScrollView.layer.borderWidth = 1;
    //弯曲的长度
    _detailScrollView.layer.cornerRadius = 5;





}
@end
